package com.mall4j.cloud.api.coupon.bo;

// 优惠卷计算抽象类，子类实现具体的计算逻辑和判断是否可用
public abstract class CouponBO {
    private long couponId;
    private String couponName;

    // 优惠卷是否可用
    public abstract boolean canUse(CouponUseContext context);
    // 根据上下文计算优惠卷的价值
    public long applyDiscount(CouponUseContext context) {
        if(!canUse(context)) {
            return 0;
        }
        return applyDiscountInternal(context);
    }
    protected abstract long applyDiscountInternal(CouponUseContext context);


    public long getCouponId() {
        return couponId;
    }

    public void setCouponId(long couponId) {
        this.couponId = couponId;
    }

    public String getCouponName() {
        return couponName;
    }

    public void setCouponName(String couponName) {
        this.couponName = couponName;
    }
}
